package com.hhxy.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 请求包含的接收方
 * @author ghp
 * @date 2022/9/20
 */
@WebServlet("/requestIncludedServlet")
public class RequestIncludedServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取打印流
        PrintWriter pw = response.getWriter();

        // 设置响应时使用的字符编码
        response.setContentType("text/html;charset=utf-8");
        pw.println("中国" + "<br>");
        pw.println("URI:" + request.getRequestURI() + "<br />");
        pw.println("QueryString:" + request.getQueryString() + "<br />");
        pw.println("parameter pl:" + request.getParameter("pl") + "<br />");
    }
}